﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kindohm.Life.Library
{
    public abstract class GrowingLifeForm : LifeForm
    {
        int growInterval;
        int growthHeartbeats;
        protected bool grew;

        public int GrowthHeartbeats
        {
            get { return this.growthHeartbeats; }
            set { this.growthHeartbeats = value; }
        }

        public int GrowInterval
        {
            get { return this.growInterval; }
            set { this.growInterval = value; }
        }

        public bool Grew
        {
            get { return this.grew; }
        }

        public override void RunHeartbeat()
        {
            this.grew = false;
            base.RunHeartbeat();

            if (this.IsDead)
            {
                return;
            }

            this.growthHeartbeats++;

            if (this.growthHeartbeats > this.growInterval)
            {
                this.growthHeartbeats = 0;
                this.Grow();
                this.grew = true;
            }
       
        }

        public abstract void Grow();
    }
}
